home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / cool / cool.lha / lice / mkdepend / cppsetup.c next >
C/C++ Source or Header  |  1991-09-04  |  2KB  |  112 lines

  1. /*
  2. //
  3. // Copyright (C) 1991 Texas Instruments Incorporated.
  4. //
  5. // Permission is granted to any individual or institution to use, copy, modify,
  6. // and distribute this software, provided that this complete copyright and
  7. // permission notice is maintained, intact, in all copies and supporting
  8. // documentation.
  9. //
  10. // Texas Instruments Incorporated provides this software "as is" without
  11. // express or implied warranty.
  12. //
  13.  * $XConsortium: cppsetup.c,v 1.5 89/06/13 19:15:36 jim Exp $
  14.  */
  15. #include "def.h"
  16.  
  17. #ifdef    CPP
  18. /*
  19.  * This file is strictly for the sake of cpy.y and yylex.c (if
  20.  * you indeed have the source for cpp).
  21.  */
  22. #define IB 1
  23. #define SB 2
  24. #define NB 4
  25. #define CB 8
  26. #define QB 16
  27. #define WB 32
  28. #define SALT '#'
  29. #if pdp11 | vax | ns16000 | mc68000 | ibm032
  30. #define COFF 128
  31. #else
  32. #define COFF 0
  33. #endif
  34. /*
  35.  * These variables used by cpy.y and yylex.c
  36.  */
  37. extern char    *outp, *inp, *newp, *pend;
  38. extern char    *ptrtab;
  39. extern char    fastab[];
  40. extern char    slotab[];
  41.  
  42. /*
  43.  * cppsetup
  44.  */
  45. struct filepointer    *currentfile;
  46. struct inclist        *currentinc;
  47.  
  48. cppsetup(line, filep, inc)
  49.     register char    *line;
  50.     register struct filepointer    *filep;
  51.     register struct inclist        *inc;
  52. {
  53.     register char *p, savec;
  54.     static boolean setupdone = FALSE;
  55.     boolean    value;
  56.  
  57.     if (!setupdone) {
  58.         cpp_varsetup();
  59.         setupdone = TRUE;
  60.     }
  61.  
  62.     currentfile = filep;
  63.     currentinc = inc;
  64.     inp = newp = line;
  65.     for (p=newp; *p; p++)
  66.         ;
  67.  
  68.     /*
  69.      * put a newline back on the end, and set up pend, etc.
  70.      */
  71.     *p++ = '\n';
  72.     savec = *p;
  73.     *p = '\0';
  74.     pend = p;
  75.  
  76.     ptrtab = slotab+COFF;
  77.     *--inp = SALT; 
  78.     outp=inp; 
  79.     value = yyparse();
  80.     *p = savec;
  81.     return(value);
  82. }
  83.  
  84. struct symtab *lookup(symbol)
  85.     char    *symbol;
  86. {
  87.     static struct symtab    undefined;
  88.     struct symtab   *sp;
  89.  
  90.     sp = defined(symbol, currentinc);
  91.     if (sp == NULL) {
  92.         sp = &undefined;
  93.         sp->s_value = NULL;
  94.     }
  95.     return (sp);
  96. }
  97.  
  98. pperror(tag, x0,x1,x2,x3,x4)
  99.     int    tag,x0,x1,x2,x3,x4;
  100. {
  101.     do_log("\"%s\", line %d: ", currentinc->i_file, currentfile->f_line);
  102.     do_log(x0,x1,x2,x3,x4);
  103. }
  104.  
  105.  
  106. yyerror(s)
  107.     register char    *s;
  108. {
  109.     log_fatal("Fatal error: %s\n", s);
  110. }
  111. #endif /* CPP */
  112.